const validatorRule = {
  
  checkField:(validatorObj,value) => {
    let bool = false,
        reg = validatorObj.pattern;
    bool = reg.test(value);
    if (!bool) {
      uni.showToast({
        icon: 'none',
        title: validatorObj.message,
        duration: 2000
      });
    }
    return bool;
  },
  
  username:{
    pattern: /^[a-zA-Z0-9_]{4,15}$/,
    message: "用户名不合法！匹配字母数字下划线，长度位3-15",
  },
  
  password:{
    pattern: /^.{6,15}$/,
    message: "密码输入不合法！长度6-15",
  },

  tel:{
    pattern: /^[1][3,4,5,7,8][0-9]{9}$|^0\d{2,3}-?\d{7,8}$/,
    message: "电话输入不合法，格式不正确！",
  },
  
  mobilePhone: {
    pattern: /^[1][3,4,5,7,8][0-9]{9}$/,
    message: "手机输入不合法，格式不正确！",
  },
  
  email:{
    pattern: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
    message: "邮箱输入不合法，格式不正确！",
  }
 

};

export default validatorRule;